TransForm onSubmit Event BuilderSet Values in 'User' Fields

Description

Sets the value of the submitted Form's 'User' or 'Userlabel' fields.

Discussion

The Set Values in 'User' Fields action can be used to set the value in one or more of the submitted Form's 'User' or 'Userlabel' fields. The 'User' and 'Userlabel' fields are top-level Form fields stored with the Form's metadata that can be used to quickly query the Forms in a TransForm account. There are five User fields (user1, user2, user3, user4, user5) and five Userlabel fields (userlabel1, userlabel2, userlabel3, userlabel4, userlabel5). These fields can be populated with Form data using this action.

Configuring the Send SMS Message Action

The Set Values in 'User' Fields Action Editor
The Set Values in 'User' Fields Action Editor

The following properties are used to configure the Set Values in 'User' Fields action.

  • General Properties

    Property
    Description
    TransForm Form Name

    The Form Type for which the 'user' or 'userlabel' fields should be set.

    Condition

    Determines when the onSubmit action should be run.

    Your code must set the value of a variable called result to true or false. For example:

    Setting the result variable
    var result =  true;

    If true, the 'user' or 'userlabel' fields will be set. If false, the fields are not set. The next example demonstrates setting the fields only when the metadata status field is set to 'closed':

    Checking the metadata status field to determine if ' user' or 'userlabel' fields should be set
    if (metadata.status.toLowerCase() == 'closed') {
        var result = true;
    } else {
        var result = false;
    }

    The code you define for the Condition can reference data in the submitted Form using the formdata and metadata variables.

    Prefix
    Description
    formdata

    A JavaScript object that contains the Form data submitted. You can use the Insert TransForm form field tool to insert a Form data field into your code if you have loaded sample Form data.

    metadata

    A JavaScript object that contains the meta data for the submitted Form. You can use the Insert TransForm form field tool to insert one of the following metadata variables into your code if you have loaded sample Form data:

    accountid

    The TransForm account ID associated with the Form.

    formid

    The Form Type ID of the Form.

    forminstanceid

    The unique instance ID of the Form.

    status

    The current status of the Form.

    person

    The User ID of the person assigned the Form instance.

    created

    The date/time the Form was created.

    completed

    The date/time when the Form's status was last changed.

    timestamp

    The date/time of when the Form was last inserted or updated in the server database.

    comments

    The representation of the JSON for the comments associated with the Form instance.

    nofiller

    Whether or not the Form should be downloaded to the filler application.

    duedate

    The value of the field in a Form instance that may be used to specify a date. It will either be blank or contain a date formatted as "yyyy-mm-dd". For example, "2024-04-16".

    user1, user2, user3, user4, user5, userlabel1, userlabel2, userlabel3, userlabel4, userlabel5

    The value of the extra fields in a Form instance reserved for use by the TransForm account's administrator.

  • 'User' fields

    Property
    Description
    'User1', 'User2', 'User3', 'User4', 'User5'

    JavaScript that specifies what value to set in the User* (User1, User2, User3, User4, or User5) Form field. Your code must set the value of a variable called result to value to set in the User* field. For example:

    var result = "My Value";

    The code you define for the User* property can reference data in the submitted Form using the formdata and metadata variables. For example:

    if(metadata.status.toLowerCase() == 'closed') {
        var result = formdata.field1
    } else { 
        var result = formdata.field2
    }

    See Condition above for more information about the formdata and metadata objects.

  • 'User label' fields

    Property
    Description
    'Userlabel1', 'Userlabel2', 'Userlabel3', 'Userlabel4', 'Userlabel5'

    JavaScript that specifies what value to set in the Userlabel* (Userlabel1, Userlabel2, Userlabel3, Userlabel4, or Userlabel5) Form field. Your code must set the value of a variable called result to value to set in the Userlabel* field. For example:

    var result = "My Value";

    The code you define for the Userlabel* property can reference data in the submitted Form using the formdata and metadata variables. For example:

    if(metadata.status.toLowerCase() == 'closed') {
        var result = formdata.field1
    } else { 
        var result = formdata.field2
    }

    See Condition above for more information about the formdata and metadata objects.